package dbUtil

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

var tableName = "users" //数据表名
var result ResponseData //响应结果数据

// 统一返回数据的结构体
type ResponseData struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func showSuccess(c *gin.Context, data interface{}) {
	result.Code = http.StatusOK
	result.Message = "操作成功"
	result.Data = data
	c.JSON(http.StatusOK, result)
	return
}

func showError(c *gin.Context, message string) {
	result.Code = http.StatusBadRequest
	result.Message = message
	result.Data = nil
	c.JSON(http.StatusOK, result)
	return
}
